package com.cby.android.sample.model

import android.app.Application
import com.cby.android.library.base.BaseStateViewModel
import com.cby.android.sample.intent.RollNewsTypeIntent
import com.cby.android.sample.repository.RollApiImpl
import com.cby.android.sample.state.RollNewsTypeState

class RollNewsViewModel(application: Application) : BaseStateViewModel<RollNewsTypeState, RollNewsTypeIntent>(application){

    private var rollApi = RollApiImpl()

    override fun dispatch(intent: RollNewsTypeIntent) {
        fetchDataWithStatus {
            val response = rollApi.getNewsTypes()
            updateState(RollNewsTypeState(response.data!!))
            response.data!!.isNotEmpty()
        }
    }
}